package edu.sctu.fengleilin.month05.day150518;

/**
 * Created by user09 on 2015/5/17.
 */
public class TextMore {
    protected Teacher[] teacher;

    public TextMore(Teacher[] teacher) {
        this.teacher = teacher;
    }

    public void sortNumber() {
        Teacher[] teacherA = new Teacher[teacher.length];
        for (int i = 0; i < (teacher.length - 1); i++) {
            for (int j = 0; j < (teacher.length - 1); j++) {
                if (teacher[j].number > teacher[j + 1].number) {
                    teacherA[0] = teacher[j];
                    teacher[j] = teacher[j + 1];
                    teacher[j + 1] = teacherA[0];
                }
            }
        }
    }

    public void sortStudent(Student[] student) {
        Student[] teacherB = new Student[student.length];
        for (int i = 0; i < (student.length - 1); i++) {
            for (int j = 0; j < (student.length - 1); j++) {
                if (student[j].score > student[j + 1].score) {
                    teacherB[0] = student[j];
                    student[j] = student[j + 1];
                    student[j + 1] = teacherB[0];
                }
            }
        }
    }

    public Teacher pritCoded() {
        Teacher returnTeacher = null;
        for (Teacher teacher : this.teacher) {
            if (teacher.work.equals("教授")) {
                returnTeacher = teacher;
            }
        }
        return returnTeacher;
    }
}

//        创建一个类为TextOne,TextOne继承自TextMore，TextMore有三个方法，sotrNumber()一个是对老师学号进行排序，
//        sortStudent()一个是对老师所教学生成绩进行排序。pritCoded()一个是对老师职称为教授的进行返回